#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    /*
        创建buffer的size=12
        写1：abcd     abcd         0
        写2：efghi   abcdefghi     0
        读1：abcd    abcdefghi     4
        写3：jklmno  mnodefghijkl  4
        读2：efghi   mnodefghijkl  9
        读3：jklmno  mnodefghijkl  3
    */
    Buffer *buffer = app_buffer_init(12);
    app_buffer_write(buffer, "abcd", 4);
    app_buffer_write(buffer, "efghi", 5);
    char data1[4];
    app_buffer_read(buffer, data1, 4);
    log_debug("data1=%s", data1);
    app_buffer_write(buffer, "jklmno", 6);
    char data2[5];
    app_buffer_read(buffer, data2, 5);
    log_debug("data2=%s", data2);
    char data3[6];
    app_buffer_read(buffer, data3, 6);
    log_debug("data3=%s", data3);


    app_buffer_free(buffer);

    return 0;
}
